package belastungstest.mobapp.fhfl.mobappbelastungstest;

import belastungstest.mobapp.fhfl.mobappbelastungstest.Transmitter.*;

import android.app.FragmentManager;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import java.net.InetAddress;
import java.text.DecimalFormat;

import android.os.Handler;

import org.achartengine.GraphicalView;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;


public class MyActivity extends FragmentActivity {
    private Fragment_Setting fragment_setting = null;
    private Fragment_Graph fragment_graph = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        fragment_graph = new Fragment_Graph();
        fragment_setting = new Fragment_Setting();

        setContentView(R.layout.fragments);
        getFragmentManager().beginTransaction().
                replace(R.id.container, fragment_setting).
                addToBackStack(null).
                commit();
        fragment_graph.setGraphView( fragment_setting.getChartView() );


    }

    //region OptionsMenu
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        MenuInflater inflater=getMenuInflater();
        inflater.inflate(R.menu.my, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        switch (id)
        {
            case R.id.action_settings:
                getFragmentManager().beginTransaction().
                        replace(R.id.container, fragment_setting).
                        addToBackStack(null).
                        commit();
                return true;
            case R.id.action_graph:
                    fragment_graph.setGraphView( fragment_setting.getChartView() );
                getFragmentManager().beginTransaction().
                        replace(R.id.container, fragment_graph).
                        addToBackStack(null).
                        commit();
                return true;
        }

        return super.onOptionsItemSelected(item);
    }

    //endregion
}
